home *** CD-ROM | disk | FTP | other *** search
/ New Star Software Collection / NSS_Collection.iso / 3-004 ms visual basic pro 30 / 4.imz / 4.IMA / REPLACE.FR_ / REPLACE.bin
Text File  |  1993-04-28  |  5KB  |  200 lines

  1. VERSION 2.00
  2. Begin Form fReplace 
  3.    BackColor       =   &H00C0C0C0&
  4.    BorderStyle     =   1  'Fixed Single
  5.    Caption         =   "Record Replace"
  6.    ClientHeight    =   3390
  7.    ClientLeft      =   3630
  8.    ClientTop       =   2850
  9.    ClientWidth     =   5160
  10.    ControlBox      =   0   'False
  11.    Height          =   3795
  12.    Icon            =   REPLACE.FRX:0000
  13.    Left            =   3570
  14.    LinkTopic       =   "Form1"
  15.    MaxButton       =   0   'False
  16.    MinButton       =   0   'False
  17.    ScaleHeight     =   3372
  18.    ScaleMode       =   0  'User
  19.    ScaleWidth      =   5184
  20.    Top             =   2505
  21.    Width           =   5280
  22.    Begin ListBox cTableList 
  23.       BackColor       =   &H00FFFFFF&
  24.       Height          =   1560
  25.       Left            =   240
  26.       Sorted          =   -1  'True
  27.       TabIndex        =   9
  28.       Tag             =   "OL"
  29.       Top             =   360
  30.       Width           =   2292
  31.    End
  32.    Begin ListBox cFieldList 
  33.       BackColor       =   &H00FFFFFF&
  34.       Height          =   1560
  35.       Left            =   2640
  36.       Sorted          =   -1  'True
  37.       TabIndex        =   0
  38.       Tag             =   "OL"
  39.       Top             =   360
  40.       Width           =   2292
  41.    End
  42.    Begin TextBox cReplaceWith 
  43.       BackColor       =   &H00FFFFFF&
  44.       Height          =   288
  45.       Left            =   1800
  46.       TabIndex        =   5
  47.       Tag             =   "OL"
  48.       Top             =   2040
  49.       Width           =   3132
  50.    End
  51.    Begin TextBox cCondition 
  52.       BackColor       =   &H00FFFFFF&
  53.       Height          =   288
  54.       Left            =   1800
  55.       TabIndex        =   7
  56.       Tag             =   "OL"
  57.       Top             =   2400
  58.       Width           =   3132
  59.    End
  60.    Begin CommandButton OkayButton 
  61.       BackColor       =   &H00C0C0C0&
  62.       Caption         =   "&OK"
  63.       Default         =   -1  'True
  64.       Enabled         =   0   'False
  65.       Height          =   372
  66.       Left            =   600
  67.       TabIndex        =   3
  68.       Top             =   2880
  69.       Width           =   1692
  70.    End
  71.    Begin CommandButton CancelButton 
  72.       BackColor       =   &H00C0C0C0&
  73.       Cancel          =   -1  'True
  74.       Caption         =   "&Close"
  75.       Height          =   372
  76.       Left            =   2880
  77.       TabIndex        =   4
  78.       Top             =   2880
  79.       Width           =   1692
  80.    End
  81.    Begin Label TableListLabel 
  82.       BackColor       =   &H00C0C0C0&
  83.       Caption         =   "Table List:"
  84.       Height          =   190
  85.       Left            =   240
  86.       TabIndex        =   8
  87.       Top             =   120
  88.       Width           =   1212
  89.    End
  90.    Begin Label ConditionLabel 
  91.       BackColor       =   &H00C0C0C0&
  92.       Caption         =   "Condition:"
  93.       Height          =   252
  94.       Left            =   240
  95.       TabIndex        =   6
  96.       Top             =   2400
  97.       Width           =   1332
  98.    End
  99.    Begin Label ReplaceWithLabel 
  100.       BackColor       =   &H00C0C0C0&
  101.       Caption         =   "Replace With:"
  102.       Height          =   252
  103.       Left            =   240
  104.       TabIndex        =   2
  105.       Top             =   2040
  106.       Width           =   1452
  107.    End
  108.    Begin Label FieldListLabel 
  109.       BackColor       =   &H00C0C0C0&
  110.       Caption         =   "Field List:"
  111.       Height          =   190
  112.       Left            =   2640
  113.       TabIndex        =   1
  114.       Top             =   120
  115.       Width           =   1212
  116.    End
  117. End
  118. Option Explicit
  119.  
  120. Sub CancelButton_Click ()
  121.   Unload Me
  122. End Sub
  123.  
  124. Sub cFieldList_Click ()
  125.   If cFieldList <> "" And cReplaceWith <> "" Then
  126.     OkayButton.Enabled = True
  127.   Else
  128.     OkayButton.Enabled = False
  129.   End If
  130. End Sub
  131.  
  132. Sub cReplaceWith_Change ()
  133.   If cFieldList <> "" And cReplaceWith <> "" Then
  134.     OkayButton.Enabled = True
  135.   Else
  136.     OkayButton.Enabled = False
  137.   End If
  138. End Sub
  139.  
  140. Sub cTableList_Click ()
  141.   Dim i As Integer
  142.  
  143.   cFieldList.Clear
  144.   For i = 0 To gCurrentDB.TableDefs(cTableList).Fields.Count - 1
  145.     cFieldList.AddItem gCurrentDB.TableDefs(cTableList).Fields(i).Name
  146.   Next
  147. End Sub
  148.  
  149. Sub Form_Load ()
  150.   Height = 3792
  151.   Width = 5280
  152.   Left = (Screen.Width - Width) / 2
  153.   Top = (Screen.Height - Height) / 2
  154. End Sub
  155.  
  156. Sub Form_Paint ()
  157.   Outlines Me
  158. End Sub
  159.  
  160. Sub OkayButton_Click ()
  161.   Dim rp As String      'replace with string
  162.   Dim wh As String      'where condition
  163.   Dim r As Long         'return from execute sql
  164.  
  165.   On Error GoTo ReplaceErr
  166.  
  167.   MsgBar "Replacing Records", True
  168.   If gCurrentDB.TableDefs(cTableList).Fields(cFieldList).Type = FT_STRING Then
  169.     rp = "'" + cReplaceWith + "'"
  170.   Else
  171.     rp = cReplaceWith
  172.   End If
  173.   If cCondition = "" Then
  174.     wh = ""
  175.   Else
  176.     wh = " where " + cCondition
  177.   End If
  178.   If gstDataType = "ODBC" Then
  179.     r = gCurrentDB.ExecuteSQL("update " + cTableList + " set " + cFieldList + "=" + rp + wh)
  180.     If r > 0 Then
  181.       If gfTransPending Then gfDBChanged = True
  182.     End If
  183.   Else
  184.     gCurrentDB.Execute "update " + cTableList + " set [" + cFieldList + "]=" + rp + wh
  185.   End If
  186.  
  187.   Unload Me
  188.  
  189.   GoTo ReplaceEnd
  190.  
  191. ReplaceErr:
  192.   ShowError
  193.   Resume ReplaceEnd
  194.  
  195. ReplaceEnd:
  196.   MsgBar "", False
  197.   
  198. End Sub
  199.  
  200.